package com.ruoyi.psi.purchase.pay.mapper;

import com.ruoyi.psi.purchase.pay.domain.PurchasePay;
import com.ruoyi.psi.purchase.pay.domain.PurchasePayList;
import com.ruoyi.psi.purchase.purchasereturn.domain.PurchaseReturnList;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 采购付款/委外付款
 * 数据层
 * @author Drj 2021/6/28
 */
public interface PurchasePayMapper {
    /**
     * 查询所有采购付款
     * @param purchasePay 搜索条件
     * @return
     */
    public List<PurchasePay> selectPurchasePayList(PurchasePay purchasePay);

    /**
     * 根据编号查询
     * @param purchasePayId 采购付款编号
     * @return
     */
    public PurchasePay selectPurchasePayById(String purchasePayId);

    /**
     * 获取最新的一条采购付款编号
     * @return
     */
    public String getPurchasePayId();

    /**
     * 新增采购付款
     * @param purchasePay
     * @return
     */
    public int insertPurchasePay(PurchasePay purchasePay);

    /**
     * 更新采购付款
     * @param purchasePay
     * @return
     */
    public int updatePurchasePay(PurchasePay purchasePay);

    /**
     * 删除采购付款
     * @param purchasePay
     * @return
     */
    public int updatePurchasePayDeleteFlag(PurchasePay purchasePay);


//付款详细

    /**
     * 根据采购订单编号、采购付款编号查询
     * @param purchasePayList
     * @return
     */
    public PurchasePayList selectPurchasePayListById(PurchasePayList purchasePayList);
    /**
     * 付款单对应付款详细（不包含入库金额，已付款金额）
     * @param purchasePayId 采购付款编号
     * @return
     */
    public List<PurchasePayList> selectPurchasePayListListById(String purchasePayId);

    /**
     * 已入库金额
     * @param purchaseOrderId 采购订单编号
     * @return
     */
    public Double getPurchaseStoragePriceById(String purchaseOrderId);

    /**
     * 已付款金额
     * @param purchaseOrderId 采购订单编号
     * @return
     */
    public Double getAmountPaidById(String purchaseOrderId);

    /**
     * 新增采购详细
     * @param purchasePayList
     * @return
     */
    public int insertPurchasePayList(PurchasePayList purchasePayList);

    /**
     * 更新采购详细
     * @param purchasePayList
     * @return
     */
    public int updatePurchasePayList(PurchasePayList purchasePayList);

    /**
     * 删除采购详细
     * @param purchasePayList
     * @return
     */
    public int deletePurchasePayList(PurchasePayList purchasePayList);
    /**
     * 新增付款单时查询对应采购订单、采购退货（委外订单暂定）
     * @param supplierInfoId
     * @return
     */
    public List<PurchasePayList> getPayBill(String supplierInfoId);

    /**
     * 获取已付款项
     * @param purchaseOrderId 单据编号
     * @param payType 单据类型
     * @return
     */
    public Double getAmountPaid(@Param("purchaseOrderId") String purchaseOrderId, @Param("payType") String payType);

    /**
     * 获取采购退回金额
     * @param purchaseReturnId 采购退回编号
     * @return
     */
    public Double getBillNum(String purchaseReturnId);
}
